// 封装存储 持久化存储

// 初始化 持久化
export const init=(...rest)=>{
  // console.log(JSON.stringify(rest))
  // PersistentStorage.persistProp(key,undefined)
  rest.map(key=>{
    PersistentStorage.persistProp(key,undefined)
  })
}
// 存 取 清

export const set=(key,val)=>{
  let data:string=JSON.stringify(val)
  AppStorage.setOrCreate(key,data)
}
export const get=(key)=>{
  let data:string=AppStorage.get(key)
  // console.log(typeof data)
  if(data==undefined || data=='undefined'){
    return undefined
  }
  if(data==null || data=='null'){
    return null
  }
  let res=JSON.parse(data)
  return res
}

export const clear=(...rest)=>{
  AppStorage.clear()
  // PersistentStorage.deleteProp()
  rest.map(key=>{
    PersistentStorage.deleteProp(key)
  })
}
